package com.dinggao.bangda.data;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dinggao.bangda.R;

import java.util.List;

/**
 * Created by Administrator on 2017/4/20.
 */

public class LogisticsAdapter extends RecyclerView.Adapter<LogisticsAdapter.ViewHolder>{
    private List<Logistics> mLogisticsList;
    private Logistics logistics;
    public class ViewHolder extends RecyclerView.ViewHolder{
        View logisticsView;
        TextView name;
        //初始化各控件
        public ViewHolder(final View itemView) {
            super(itemView);
            logisticsView = itemView;
            name = (TextView) itemView.findViewById(R.id.name_logistics);
        }
    }

    public LogisticsAdapter(List<Logistics> logisticsList){
        mLogisticsList = logisticsList;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_logistics,parent,false);
        final ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(LogisticsAdapter.ViewHolder holder, int position) {
        logistics = mLogisticsList.get(position);
        holder.name.setText(logistics.getName_logistics());

    }

    @Override
    public int getItemCount() {
        return mLogisticsList.size();
    }
}
